<script setup>
import { ref, defineProps, onMounted } from 'vue'
const props = defineProps({
    data: {
        type: Object,
        default: () => ({})
    }
})

</script>

<template>
    <div class="card-box">
        <div class="card-img">
            <img :src="data.articleImg ? data.articleImg : '/default.jpg'" alt="">
        </div>
        <div class="card-text">
            <ul class="card-title">

                <li class="title">{{ data.title ? data.title : '标题加载中……' }}</li>
                <li>{{ data.describe ? data.describe : '描述加载中……' }}</li>
            </ul>
            <ul>
                <li>
                    <svg class="icon" aria-hidden="true">
                        <use xlink:href="#icon-shijian2"></use>
                    </svg>
                    <span> {{ data.time ? data.time : "2024-01-01" }}</span>
                </li>
                <li>
                    <svg class="icon" aria-hidden="true">
                        <use xlink:href="#icon-yanjing"></use>
                    </svg>
                    <span>
                        {{ (data.views ? data.views : '10086') }}
                    </span>
                </li>
                <li>
                    <svg class="icon" aria-hidden="true">
                        <use xlink:href="#icon-good"></use>
                    </svg>
                    <span>
                        {{ data.likes ? data.likes : '23' }}
                    </span>
                </li>
            </ul>
        </div>
    </div>

</template>

<style lang="scss" scoped>
@keyframes change {
    0% {
        transform: translate(0, -100px) scale(1.05);
    }

    50% {
        transform: translate(0px, -50px) scale(1.02);
    }

    100% {
        transform: translate(0px) (1);
    }
}

.card-box {
    width: 100%;
    height: 150px;
    display: flex;
    padding: 10px;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    overflow: hidden;
    margin: 20px 0;
    animation: change .5s linear;

    &:hover {
        cursor: pointer;
        transform: translateY(-5px);
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
    }

    .card-img {
        width: 300px;
        height: 100%;
        border-radius: 10px;
        margin-right: 20px;
        overflow: hidden;

        img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }
    }

    .card-text {
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: space-between;

        .card-title {
            display: flex;
            flex-direction: column;
            align-items: top;

            li {
                font-size: 14px;
                color: #666;
                margin-bottom: 10px;


                &.title {
                    font-size: 18px;
                    color: #333;
                    font-weight: bold;
                }
            }
        }

        &>ul:last-child {
            display: flex;
            justify-content: left;
            align-items: center;
            font-size: 12px;
            color: #999;

            li {
                margin-right: 10px;
                display: flex;
                align-items: center;

                .icon {
                    width: 20px;
                    height: 20px;
                    vertical-align: -0.15em;
                    fill: currentColor;
                    overflow: hidden;
                }

                span {
                    margin-left: 5px;
                }
            }
        }
    }
}
</style>